package leetcode100;

// TODO 脑筋急转弯 | 快慢指针 【-】 环形链表
// TODO https://leetcode.cn/problems/linked-list-cycle/solution/kuai-man-zhi-zhen-jie-ti-by-hang-3k-4wn1/

public class lc100_0141 {
    public boolean hasCycle(ListNode head) {
        ListNode slow=head;
        ListNode fast=head;
        while(fast!=null && fast.next!=null && fast.next.next!=null){
            fast=fast.next.next.next;
            slow=slow.next;
            if(fast==slow){
                return true;
            }
        }
        return false;
    }
}